package com.jjb.www.ui.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;

import com.hjq.shape.view.ShapeTextView;
import com.jjb.www.R;
import com.jjb.www.app.AppAdapter;
import com.jjb.www.http.api.UserChangeListApi;

/**
 *    author : Android CRG
 *    github : https://github.com/getActivity/AndroidProject
 *    time   : 2018/11/05
 *    desc   : 可进行拷贝的副本
 */
public final class VipAdapter extends AppAdapter<UserChangeListApi.Bean.ListDTO> {

    public VipAdapter(Context context) {
        super(context);
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder();
    }

    private final class ViewHolder extends AppAdapter<?>.ViewHolder {
        private ShapeTextView mTvItem;

        private ViewHolder() {
            super(R.layout.item_vip);
            mTvItem = findViewById(R.id.tv_item);
        }

        @Override
        public void onBindView(int position) {
            mTvItem.setText(getItem(position).getName1());
            if (getItem(position).getMember_type()==1){
                mTvItem.getShapeDrawableBuilder()
                        .setSolidColor(ContextCompat.getColor(getContext(), R.color.color_3B3F4D))
                        .setStrokeColor(ContextCompat.getColor(getContext(), R.color.color_DCB57F))
                        .setStrokeWidth(1)
                        .intoBackground();
                mTvItem.getTextColorBuilder()
                        .setTextColor(ContextCompat.getColor(getContext(), R.color.color_DCB57F))
                        .intoTextColor();
            }else {
                int[] normalColor = {ContextCompat.getColor(getContext(), R.color.color_F1DBAC),
                        ContextCompat.getColor(getContext(), R.color.color_F1DBAC),
                        ContextCompat.getColor(getContext(), R.color.color_DBB37C)};
                mTvItem.getShapeDrawableBuilder()
                        .setGradientColor(normalColor)
                        .setStrokeColor(ContextCompat.getColor(getContext(), R.color.color_DCB57F))
                        .setStrokeWidth(1)
                        .intoBackground();
                mTvItem.getTextColorBuilder()
                        .setTextColor(ContextCompat.getColor(getContext(), R.color.color_2F2F2F))
                        .intoTextColor();
            }
        }
    }
}